package AggregationMethod;

import java.util.ArrayList;

import Definitions.NodeClass;
import Sampling.SamplingAbstractClass;

/*****************************************************************
* Name : ProportionMethod
* Aim : This class aims to keep the methods for the ProportionMethod Neighborhood 
* Calculation Function type and inherited from the NeighbourhoodFunction *
* * Algorithms: 1 2 3 0 5 -> 1/11 2/11 3/11 0 5/11
*****************************************************************/
public class ProportionMethodClass extends NeighbourhoodFunctionAbstractClass 
{
	
	public ProportionMethodClass(SamplingAbstractClass currentSampling){
		super(currentSampling);
		// TODO Auto-generated constructor stub
		name="ProportionMethod";
	}
	/*****************************************************************
	* Function Name: 	proportionMethod
	* Aim: 				perform the proportionMethod
	* Inputs: 			ArrayList<Node> node : The neighbors that will be used for the method
	* 					int usePredictOrActual : Predicted Classes or actual classes will be used 
	* 											when choosing neighbors
	* Outputs: 			sumList
	* Data Structures:  ---
	* Algorithms: 		---
	*****************************************************************/
	public ArrayList<Double> getAggregatedNeighbourVector(ArrayList<NodeClass> nodeList) 
	{
		ArrayList<Double> countOfEdges = new ArrayList<Double>();
		double sizeOfNeighbours = nodeList.size();
		countOfEdges = this.countEdge(nodeList);
		
		if (sizeOfNeighbours == 0)
		{
			
			return currentSampling.classRatiosOfTrain;
		}
		
		for (int i = 0; i < countOfEdges.size(); i++)
		{
			double sum = countOfEdges.get(i);
			countOfEdges.set(i, sum / sizeOfNeighbours);
		}
		
		return countOfEdges;
	}	
}
